package com.yc.storage.entity;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yc.base.BaseSimpleEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serial;

/**
 * <p>
 * 文件管理
 * </p>
 *
 * @author bao
 * @since 2022-04-10
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@NoArgsConstructor
@TableName("yc_file_storage")
@ApiModel(value="FileStorage对象", description="文件管理")
public class FileStorage extends BaseSimpleEntity {


    @Serial
    private static final long serialVersionUID = -1487819890738471907L;
    @ApiModelProperty(value = "名字")
    @TableField("name")
    private String name;

    @ApiModelProperty(value = "文件大小")
    @TableField("size")
    private Long size;

    @ApiModelProperty(value = "md5")
    @TableField("md5")
    private String md5;

    @ApiModelProperty(value = "路径")
    @TableField("path")
    private String path;

    @ApiModelProperty(value = "后缀")
    @TableField("suffix")
    private String suffix;

    @ApiModelProperty(value = "真名")
    @TableField("real_name")
    private String realName;


    public void copy(FileStorage source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
